package com.zhiguang.cms.dao;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.zhiguang.cms.entity.User;

public interface UserMapper {

	/**
	 * 
	 * @param user
	 * @return
	 */
	@Insert("INSERT INTO cms_user(username,password,locked,create_time,update_time,role) "
			+ "VALUES(#{username},#{password},0,now(),now(),0)")
	int add(User user);

	@Select("SELECT id,username,password,locked,role FROM cms_user WHERE username=#{value}")
	User findByName(String username);

	@Select("SELECT id,username,password,locked,role,create_time createTime "
			+ " FROM cms_user ORDER BY create_time DESC")
	List<User> list();

	
	@Update("UPDATE cms_user set locked=#{lock} "
			+ " WHERE id=#{userId}")
	int updateLocked(@Param("userId") int userid, @Param("lock") int status);
	

}
